package com.dispacher.processor.impl;

import com.dispacher.config.Constants;
import com.dispacher.config.GlobalConfig;
import com.dispacher.processor.Processor;

public class DirectJspProcessor implements Processor {
	String default_jsp_folder = GlobalConfig.getProperty("jsp.folder");
	String url;

	public void setRequestURL(String url) {
		this.url = url;
	}

	public String doProcess() {
		if (default_jsp_folder == null || default_jsp_folder.trim().length() == 0) {
			default_jsp_folder = "/";
		}
		if (default_jsp_folder.endsWith("/")) {
			default_jsp_folder = default_jsp_folder.substring(0, default_jsp_folder.length() - 1);
		}
		String result = default_jsp_folder + "/" + url.substring(url.indexOf(Constants.DIRECT_URL_SUFFIX) + 2) + ".jsp";
		return result;
	}

}
